// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'


Shader  "Hidden/HeightDepthOfField" {

	Properties
	 {
 _MainTex ("Base", 2D) = "" {}
 _TapLowBackground ("TapLowBackground", 2D) = "" {}
 _TapLowForeground ("TapLowForeground", 2D) = "" {}
 _TapMedium ("TapMedium", 2D) = "" {}
}

	

	SubShader
     {
  ZTest Always
  ZWrite Off
  Cull Off
  Fog { Mode Off }

    LOD 100
	Pass
	{
	
	

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#include "UnityCG.cginc"
	#define Fixed3(value)  fixed3(value, value,value)
	#define Fixed4(value)  fixed4(value, value,value,value)

	struct VertexInput {
    fixed4 vertex : POSITION;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed4 tangent : TANGENT;
    fixed3 normal : NORMAL;
    //fixed4 xlv_COLOR : COLOR;
	//VertexInput
	};


	struct VertexOutput {
	fixed4 pos : SV_POSITION;
    UNITY_FOG_COORDS(1)
    //fixed4 xlv_COLOR : COLOR;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed3 xlv_TEXCOORD4 : TEXCOORD4;
	//VertexOutput
	};
	

 sampler2D _MainTex;
 sampler2D _TapLowForeground;
 float _ForegroundBlurExtrude;
 ;




	VertexOutput vert (VertexInput v)
	{
	VertexOutput o;
	//o.pos = UnityObjectToClipPos (v.vertex);
	//o.xlv_TEXCOORD0 = TRANSFORM_TEX(v.xlv_TEXCOORD0, _MainTex);
	
  float2 tmpvar_1;
  half2 tmpvar_2;
  tmpvar_2 = v.xlv_TEXCOORD0;
  tmpvar_1 = tmpvar_2;
  o.pos = UnityObjectToClipPos( v.vertex);
  o.xlv_TEXCOORD0 = tmpvar_1;

    UNITY_TRANSFER_FOG(o,o.vertex);
   
	return o;
	}


	fixed4 frag(VertexOutput i) : SV_Target
    {
    //fixed4 tmpvar_2 = tex2D(_MainTex, i.uv);
	
  half4 tapMedium_1;
  half4 fgColor_2;
  half4 fgBlur_3;
  fixed4 tmpvar_4;
  tmpvar_4 = tex2D (_TapLowForeground, i.xlv_TEXCOORD0);
  fgBlur_3 = tmpvar_4;
  fixed4 tmpvar_5;
  tmpvar_5 = tex2D (_MainTex, i.xlv_TEXCOORD0);
  fgColor_2 = tmpvar_5;
  half tmpvar_6;
  tmpvar_6 = max (fgColor_2.w, ((2.0 * fgBlur_3.w) - fgColor_2.w));
  float tmpvar_7;
  tmpvar_7 = (tmpvar_6 * _ForegroundBlurExtrude);
  fgBlur_3.w = tmpvar_7;
  half4 tmpvar_8;
  tmpvar_8.xyz = fixed3(1.0, 1.0, 0.0);
  tmpvar_8.w = fgBlur_3.w;
  tapMedium_1.w = tmpvar_8.w;
  tapMedium_1.xyz = (0.5 * (fixed3(1.0, 1.0, 0.0) + fgColor_2.xyz));
  fgBlur_3.xyz = (0.5 * (fgBlur_3.xyz + fixed3(0.0, 1.0, 0.0)));
  fgBlur_3.xyz = lerp (tapMedium_1.xyz, fgBlur_3.xyz, Fixed3(clamp ((fgBlur_3.w * fgBlur_3.w), 0.0, 1.0)));
	UNITY_APPLY_FOG(i.fogCoord, tmpvar_5);
  return lerp (fgColor_2, fgBlur_3, Fixed4(clamp (fgBlur_3.w, 0.0, 1.0)));

	}
	ENDCG
	}
  }
Fallback "Diffuse"
}

